import {createStore, applyMiddleware} from 'redux'
import reducer from '../reducers'

import {Provider} from 'react-redux'
import createLogger from 'redux-logger';
import thunkMiddleware from 'redux-thunk';

const loggerMiddleware = createLogger();
const middlewares = [thunkMiddleware];

if (process.env.NODE_ENV === 'development') {
    const logger = createLogger();
    middlewares.push(logger);
}

let store = createStore(reducer,
    applyMiddleware(...middlewares)
);

export default React.createClass({
    render(){
        return (
            <Provider store={store}>{this.props.children}</Provider>
        );
    }
});